import { observable, action, makeObservable } from "mobx";
import { PageDateSelect } from '@/types/pages/enum'
import { IProductStoreFull } from "@/types/pages/materialStore/interface";
import {getProductPieChart,getWarnInfoList,getMaterialPieChart,getMaterialStoreListData,getTendencyLineChart} from "@/api/productStore";
import { IStore } from "@/types/pages/base";

/**
 * class ProductStore
 * 产成品仓贮
 */
class ProductStore implements IStore<IProductStoreFull>  {
    @observable screenData: IProductStoreFull= {materialStoreList:{begin:{}, end:{}, in:{}, out:{}}, materialPie:{}, product:{},tendencyLine:{},wranInfo:{one:{}, two:{}, three:{}}}

    constructor() {
      makeObservable(this)
  }
   /**
     *
     * @param type 日期选择函数
     * @param date 传入日期
     */
     @action async getScreenData(type: PageDateSelect,date?:Date) {

        // 获取左上部分
        this.screenData.materialStoreList=await getMaterialStoreListData(type,date);
        this.screenData.materialPie= await getMaterialPieChart(type,date);
        this.screenData.product= await getProductPieChart(type,date);
        this.screenData.tendencyLine= await getTendencyLineChart(type,date);
        this.screenData.wranInfo=await  getWarnInfoList(type,date);
        return  this.screenData;
    }




}
export default ProductStore;
